package org.divineryang.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.divineryang.mapper.BrandMapper;
import org.divineryang.model.entity.product.Brand;
import org.divineryang.service.BrandService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @program new-bee
 * @Description
 * @Author Diviner Yang
 * @Date 2024/04/25 9:58
 * @Version 1.0
 */
@Service
public class BrandServiceImpl implements BrandService {
    @Autowired
    private BrandMapper brandMapper;
    @Override
    public PageInfo<Brand> findByPage(Integer page, Integer limit) {
        PageHelper.startPage(page,limit);
        List<Brand> pageBrand = brandMapper.findByPage();
        PageInfo<Brand> info = new PageInfo<>(pageBrand);
        return info;
    }

    @Override
    public void save(Brand brand) {
        brandMapper.save(brand);
    }

    @Override
    public void updateById(Brand brand) {
        brandMapper.updateById(brand);
    }

    @Override
    public void deleteById(Long id) {
        brandMapper.deleteById(id);
    }

    @Override
    public List<Brand> findAll() {
        List<Brand> brands=brandMapper.findByPage();
        return brands;
    }
}
